
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region Hobbies Model -(by fangyifeng at 2007-09-14 12:24:07)

	/// <summary>
	/// Hobbies object'Hobbies'.
	/// </summary>
	[Serializable]
	public class Hobbies : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected string _name;
        protected string _memo;
        protected string _stockcode;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public Hobbies() { }

        public Hobbies(string name, string memo, string stockcode)
        {
            _stockcode = stockcode;
            this._name = name;
            _memo = memo;
        }

		#endregion

		#region Public Properties

        public virtual string Memo
        {
            get { return _memo; }
            set
            {
                _memo = value;
            }
        }

        public virtual string StockCode
        {
            get { return _stockcode; }
            set
            {
                _stockcode = value;
            }
        }

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual string Name
		{
			get { return _name; }
			set
			{
				if ( value != null && value.Length > 1000)
					throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
				_name = value;
			}
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
            if (!(obj is Hobbies))
				throw new InvalidCastException("This object is not of type Hobbies");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
                    relativeValue = this.Id.CompareTo(((Hobbies)obj).Id);
					break;
				case "Name":
                    relativeValue = this.Name.CompareTo(((Hobbies)obj).Name);
					break;
                default:
                    goto case "Id";
			}
            if (Hobbies.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
